package com.singleton.pattern.singleton.demo;

/**
 * @Classname LazySingleton
 * @Description 懒汉模式(即懒加载)
 * @Date 2019/11/20 0020 15:30
 * @Created by 埔枘
 */
public class LazySingleton {

    private LazySingleton(){}

    public static LazySingleton lazySingleton = null;

    /**
     *  外部调用时 才会加载
     * @return
     */
    public static synchronized LazySingleton getSingleton(){
        if(lazySingleton == null){
            lazySingleton = new LazySingleton();
        }
        return lazySingleton;
    }
}
